﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private System.Windows.Forms.TextBox txttoantu1;
        private System.Windows.Forms.TextBox txttoantu2;
        private System.Windows.Forms.RadioButton rdbcong;
        private System.Windows.Forms.RadioButton rdbtru;
        private System.Windows.Forms.Button bttinh;
        private System.Windows.Forms.TextBox txtpheptinh;
        private System.Windows.Forms.TextBox txtketqua;
        private System.Windows.Forms.Button thoast;
        private System.Windows.Forms.Button thoatok;
        private System.Windows.Forms.Button thoatokxxx;

        public Form1()
        {
            InitializeComponent();
        }


        

       

        private void bttinh_Click(object sender, EventArgs e)
        {
            try
            {
                if (rdbcong.Checked) PHEPTINHCONG();
                else (rdbtru.Checked)PHEPTINHTRU();

            }
            catch (Exception caught) {
                txtpheptinh.Text = "";
                txtketqua.Text = caught.Message;
            }

        }
        private void PHEPTINHCONG() {
            int toantu1 = int.Parse(txttoantu1.Text);
            int toantu2 = int.Parse(txttoantu2.Text);
            int ketqua;
            ketqua = txttoantu1 + txttoantu2;
            txtpheptinh.Text = txttoantu1.Text + "+" + txttoantu2.Text;
        }
        private void PHEPTINHTRU()
        {
            int toantu1 = int.Parse(txttoantu1.Text);
            int toantu2 = int.Parse(txttoantu2.Text);
            int ketqua;
            ketqua = txttoantu1 - txttoantu2;
            txtpheptinh.Text = txttoantu1.Text + "+" + txttoantu2.Text;
        }

        private void Thot_Click(object sender, EventArgs e)
        {
            Application.Exit();            
        }
    }
}
